﻿using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Text;

namespace Ace.Web.Mvc.Common
{

    public class RedisHelper
    {
        /*
         * StackExchange.Redis
         */
        static IDatabase redis;
        static object lobject = new object();
        public RedisHelper()
        {
            if (redis == null)
            {
                lock (lobject)
                {
                    if (redis == null)
                    {
                        var connectionstr = Globals.Configuration["redis:connections"];
                        ConnectionMultiplexer connectionMultiplexer = ConnectionMultiplexer.Connect(connectionstr);
                        redis = connectionMultiplexer.GetDatabase();
                        
                    }
                }
            }

        }

        public IDatabase Redis { get { return redis; } }
    }
}
